<template>
  <a :href="toProcess"
     @click.prevent="go()"
     class="router-go-wrapper">
    <slot></slot>
  </a>
</template>

<script type="text/ecmascript-6">

  export default {
    name: 'router-go',
    props: {
      path: String,
      redirect: {
        type: Boolean,
        default: function () { //这个如果需要强制跳转并刷新页面，可以采用这个。比如：任何页面跳转到A页面都需要ssr，这个时候采取强制刷新
          return false
        }
      }
    },
    components: {},
    data() {
      return {}
    },
    computed: {
      //这里处理to的方式
      toProcess() {
        return this.path
      }
    },
    watch: {},
    mounted() {
    },
    methods: {
      go() {
        this.$emit('click')
        if (this.redirect) {
          window.location.href = this.path
        } else {
          this.$$redirect(this.path)
        }
      }
    }
  }
</script>

<style lang="stylus" type="text/stylus" scoped>
  .router-go-wrapper
    cursor pointer
</style>
